<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #box{
      width: 100px;
      height: 100px;
      margin: 100px auto;
      background: rgb(156, 96, 56);
    }
    #box2{
      width: 100px;
      height: 100px;
      margin: 100px auto;
      background: rgb(210, 16, 228);
    }
    .ani1-enter{
      transform: translateX(-500px)  rotate(360deg); 
      opacity: 0;
    }
    .ani1-enter-active,.ani1-leave-active{
      transition: all .5s;
    }
    .ani1-leave-to{
      transform: translateX(500px) rotate(360deg);
      opacity: 0;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="change">{{ isShow?'消失':'显示' }}</button>
    <transition name="ani1" mode="out-in">
      <div key="1" id="box" v-if="isShow">111</div>
      <div key="2" id="box2" v-else>222</div>
    </transition>
    
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        isShow: false
      },
      methods: {
        change () {
          this.isShow = !this.isShow
        }
      }
    })
  </script>
</body>
</html>